package com.dnjn.happiness.emo.api.factory;

import com.dnjn.happiness.common.core.domain.R;
import com.dnjn.happiness.emo.api.RemoteUserModelScoreService;
import com.dnjn.happiness.emo.api.domain.UserModelScore;
import com.dnjn.happiness.common.core.score.dto.UserModelScoreVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class RemoteUserModelScoreFactory implements FallbackFactory<RemoteUserModelScoreService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteUserModelScoreFactory.class);

    @Override
    public RemoteUserModelScoreService create(Throwable throwable) {
        log.error("调用UserModelScore服务失败：{}" + throwable.getMessage());
        return new RemoteUserModelScoreService() {
            @Override
            public void updateUserModel(Long userId, String source) {
                log.error("更新updateUserModel 失败: {}" + throwable.getMessage());
            }

            @Override
            public R<UserModelScore> getUserModelScoreByUserIdAndType(Long userId, String rtype, String source) {
                return R.fail("查询UserModelScore 失败: {}" + throwable.getMessage());
            }

            @Override
            public R<List<UserModelScore>> getuserModelScoreList(Long userId, String source) {
                return R.fail("查询UserModelScore 列表失败: {}" + throwable.getMessage());
            }

            @Override
            public void updateUserModelScoreList(UserModelScore item, String source) {
                log.error("更新UserModelScoreList 失败: {}" + throwable.getMessage());
            }

            @Override
            public void updateUserModelScore(UserModelScoreVO vo, String source) {
                log.error("更新updateUserModelScore 失败: {}" + throwable.getMessage());
            }

            @Override
            public R<List<UserModelScore>> getListByUserId(Long userId, String source) {
                return R.fail("查询UserModelScore 列表失败: {}" + throwable.getMessage());
            }
        };
    }

}
